package com.work.game.volley.httpUtil.rewrite;

import com.android.volley.AuthFailureError;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.toolbox.StringRequest;
import com.work.game.config.UrlAddressConfig;

import java.util.HashMap;
import java.util.Map;

import cn.hutool.core.util.ObjectUtil;

public class HUCStringRequest extends StringRequest {
    private Map<String, String> requestParameter;

    public HUCStringRequest(int method, String url, Listener<String> listener,
                            ErrorListener errorListener) {
        super(method, url, listener, errorListener);
    }

    public HUCStringRequest(int method, String url, Listener<String> listener,
                            ErrorListener errorListener, Map<String, String> requestParameter) {
        super(method, url, listener, errorListener);
        this.requestParameter = requestParameter;
        if(ObjectUtil.isNotNull( this.requestParameter)){
            this.requestParameter.put("uvChannel", UrlAddressConfig.CHANNEL_PACKAGE);
        }
    }

    @Override
    protected Map<String, String> getParams() throws AuthFailureError {
        return requestParameter;
    }

    @Override
    public Map<String, String> getHeaders() throws AuthFailureError {
        long timeLong = System.currentTimeMillis();
        Map<String, String> map = new HashMap<>();
//        map.put("sign", RSAEncrypt.md5Hander(timeLong));
//        map.put("timestamp", timeLong + "");
        return map;
    }
}
